package com.example.sea.back.web.home;

import com.example.sea.back.common.context.SessionKeyContext;
import com.example.sea.core.data.user.AuthPermissionEnum;
import com.example.sea.core.data.user.entity.AuthUser;
import com.example.sea.core.data.user.model.AuthPermissionModel;
import com.example.sea.core.data.user.service.AuthPermissionService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 描述：
 *
 * @author zengyz
 * @date 2018/7/9 上午 11:54
 */

@Controller
public class IndexController {

    private Logger log=LoggerFactory.getLogger(IndexController.class);

    @Autowired
    private AuthPermissionService authPermissionService;

    /**
     * 首页
     * @param request
     * @return
     */
    @RequiresAuthentication
    @GetMapping({"/","index"})
    public String indexHtml(HttpServletRequest request){
        List<AuthPermissionModel> tree = authPermissionService.findTree(AuthPermissionEnum.TYPE_BACK_PERMISSION.getValue());
        request.setAttribute("treeList",tree);
        return "common/index";
    }

    /**
     * 欢迎页
     * @return
     */
    @RequiresAuthentication
    @GetMapping("/welcome")
    public String welcomeHtml(){
        return "common/welcome";
    }

    /**
     * 图标模版
     * @return
     */
    @RequiresAuthentication
    @GetMapping("/demo/icon")
    public String iconHtml(){
        return "common/icon";
    }
}
